import { UICompomentPool } from "../../../../com/mui/utils/UICompomentPool";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { GTextArea } from "../../../../com/mui/controls/GTextArea";
import { ScrollPolicy } from "../../../../fl/controls/ScrollPolicy";
import { GButton } from "../../../../com/mui/controls/GButton";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
import { ImgBtn } from "../copy/btn/ImgBtn";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { GImageBitmap } from "../../../../com/mui/controls/GImageBitmap";
import { GTextInput } from "../../../../com/mui/controls/GTextInput";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
import { ResouceConst } from "../../../component/gconst/ResouceConst";
import { FlowerBg } from "./FlowerBg";
import { GLabel } from "../../../../com/mui/controls/GLabel";
import { PriceLabel } from "../../../common/label/PriceLabel";
import { GCheckBox } from "../../../../com/mui/controls/GCheckBox";
import { GRadioButton } from "../../../../com/mui/controls/GRadioButton";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { ScrollBarDirection } from "../../../../fl/controls/ScrollBarDirection";
import { PageSelecter } from "./pageSelect/PageSelecter";
import { ObjCreate } from "./ObjCreate";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { ImageInfo } from "../../../../com/gengine/resource/info/ImageInfo";
import { LoaderManager } from "../../../../com/gengine/resource/LoaderManager";
import { GTabBar } from "../../../../com/mui/controls/GTabBar";
import { MuiEvent } from "../../../../com/mui/events/MuiEvent";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { GComboBox } from "../../../../com/mui/controls/GComboBox";
import { MailFriendItemCellRender } from "../mail/MailFriendItemCellRender";
import { ImagesConst } from "../../resource/ImagesConst";
import { GNumericStepper } from "../../../../com/mui/controls/GNumericStepper";
import { NumInput } from "./NumInput";
import { FireTip } from "./item/FireTip";
import { SecTimerView } from "./SecTimerView";
type int = number;
//class UIFactory
    
    export  class UIFactory
    {
        

        public disposeBitmap(arg1: Object /* flash.display.Bitmap */): void
        {
            UICompomentPool.disposeUICompoment(arg1);
            return;
        }

        public static createGTextField(arg1: string, arg2: int=0, arg3: int=0, arg4: int=220, arg5: int=20, arg6: Object /* flash.display.DisplayObjectContainer */=null, arg7: Object /* flash.text.TextFormat */=null, arg8: Boolean=false, arg9: Boolean=true): GTextFiled
        {
            var loc1;
            (loc1 = UICompomentPool.getUICompoment(GTextFiled) as GTextFiled).defaultTextFormat = arg7 ? arg7 : GlobalStyle.textFormat1;
            loc1.x = arg2;
            loc1.y = arg3;
            if (arg8) 
            {
                loc1.htmlText = arg1;
            }
            else 
            {
                loc1.text = arg1;
            }
            if (arg5 > 0) 
            {
                loc1.height = arg5;
            }
            if (arg4 > 0) 
            {
                loc1.width = arg4;
            }
            loc1.selectable = false;
            loc1.multiline = false;
            loc1.wordWrap = false;
            loc1.embedFonts = false;
            loc1.filters = [FilterConst.glowFilter];
            if (arg6) 
            {
                arg6.addChild(loc1);
            }
            if (!arg9) 
            {
                loc1.mouseWheelEnabled = false;
            }
            return loc1;
        }

        public static createTextArea(arg1: string="", arg2: int=0, arg3: int=0, arg4: int=300, arg5: int=300, arg6: Object /* flash.display.DisplayObjectContainer */=null, arg7: string="GTextArea"): GTextArea
        {
            var loc1;
            (loc1 = UICompomentPool.getUICompoment(GTextArea) as GTextArea).x = arg2;
            loc1.y = arg3;
            loc1.width = arg4;
            loc1.height = arg5;
            loc1.wordWrap = true;
            loc1.editable = false;
            loc1.verticalScrollPolicy = ScrollPolicy.AUTO;
            loc1.horizontalScrollPolicy = ScrollPolicy.OFF;
            if (arg6) 
            {
                arg6.addChild(loc1);
            }
            loc1.styleName = arg7;
            return loc1;
        }

        public static createEmbedTextFiled(arg1: string, arg2: int=0, arg3: int=0, arg4: int=220, arg5: int=20, arg6: Object /* flash.display.DisplayObjectContainer */=null, arg7: Object /* flash.text.TextFormat */=null): GTextFiled
        {
            var loc1=null;
            (loc1 = UICompomentPool.getUICompoment(GTextFiled) as GTextFiled).x = arg2;
            loc1.y = arg3;
            loc1.height = arg5;
            loc1.width = arg4;
            loc1.multiline = false;
            loc1.wordWrap = false;
            loc1.embedFonts = true;
            loc1.mouseEnabled = false;
            loc1.autoSize = flash.text.TextFieldAutoSize.NONE;
            loc1.filters = [FilterConst.glowFilter];
            if (arg6) 
            {
                arg6.addChild(loc1);
            }
            if (arg7) 
            {
                loc1.defaultTextFormat = arg7;
            }
            loc1.text = arg1;
            return loc1;
        }

        public static createAutoSizeGTextFiled(arg1: string, arg2: int, arg3: int, arg4: int, arg5: Object /* flash.display.DisplayObjectContainer */, arg6: string="left", arg7: int=3): GTextFiled
        {
            var loc1;
            (loc1 = UIFactory.createGTextField(arg1, arg2, arg3, arg4, 14, arg5)).wordWrap = true;
            loc1.multiline = true;
            loc1.autoSize = arg6;
            loc1.mouseEnabled = false;
            loc1.mouseWheelEnabled = false;
            var loc2;
            (loc2 = loc1.defaultTextFormat).leading = arg7;
            loc1.defaultTextFormat = loc2;
            return loc1;
        }

        public static createGButton(arg1: string, arg2: int=0, arg3: int=0, arg4: int=49, arg5: int=28, arg6: Object /* flash.display.DisplayObjectContainer */=null, arg7: string="Button"): GButton
        {
            var loc1;
            (loc1 = UICompomentPool.getUICompoment(GButton) as GButton).styleName = arg7;
            loc1.x = arg2;
            loc1.y = arg3;
            loc1.setSize(arg4, arg5);
            loc1.textField.filters = [FilterConst.glowFilter];
            loc1.label = arg1;
            if (arg6) 
            {
                arg6.addChild(loc1);
            }
            return loc1;
        }

        public static createGLoadedButton(arg1: string="", arg2: number=0, arg3: number=0, arg4: number=-1, arg5: number=-1, arg6: Object /* flash.display.DisplayObjectContainer */=null): GLoadedButton
        {
            var loc1;
            (loc1 = UICompomentPool.getUICompoment(GLoadedButton) as GLoadedButton).styleName = arg1;
            loc1.label = "";
            loc1.x = arg2;
            loc1.y = arg3;
            if (arg4 > 0) 
            {
                loc1.width = arg4;
            }
            if (arg5 > 0) 
            {
                loc1.height = arg5;
            }
            if (arg6) 
            {
                arg6.addChild(loc1);
            }
            return loc1;
        }

        public static createImgBtn(arg1: string, arg2: int=0, arg3: int=0, arg4: int=80, arg5: int=90, arg6: Object /* flash.display.DisplayObjectContainer */=null, arg7: string="BattleButton"): ImgBtn
        {
            var loc1=null;
            if (GlobalClass.hasRes(arg1)) 
            {
                loc1 = GlobalClass.getBitmap(arg1);
            }
            else 
            {
                loc1 = flash.display.Bitmap(new GImageBitmap(arg1));
            }
            var loc2;
            (loc2 = UICompomentPool.getUICompoment(ImgBtn, loc1, arg4, arg5, arg7) as ImgBtn).x = arg2;
            loc2.y = arg3;
            if (arg6) 
            {
                arg6.addChild(loc2);
            }
            return loc2;
        }

        public static createGTextInput(arg1: int=0, arg2: int=0, arg3: int=220, arg4: int=20, arg5: Object /* flash.display.DisplayObjectContainer */=null, arg6: string="GTextInput"): GTextInput
        {
            var loc1;
            (loc1 = UICompomentPool.getUICompoment(GTextInput)).x = arg1;
            loc1.y = arg2;
            loc1.width = arg3;
            loc1.height = arg4;
            loc1.restrict = null;
            loc1.maxChars = 999999999;
            loc1.textField.filters = [FilterConst.glowFilter];
            loc1.styleName = arg6;
            loc1.textField.wordWrap = true;
            loc1.mouseEnabled = true;
            loc1.editable = true;
            loc1.textField.wordWrap = true;
            loc1.drawNow();
            if (arg5) 
            {
                arg5.addChild(loc1);
            }
            return loc1;
        }

        public static createBg(arg1: int=0, arg2: int=0, arg3: int=-1, arg4: int=-1, arg5: Object /* flash.display.DisplayObjectContainer */=null, arg6: string="WindowCenterB"): ScaleBitmap
        {
            var loc1;
            (loc1 = ResouceConst.getScaleBitmap(arg6)).x = arg1;
            loc1.y = arg2;
            if (arg3 != -1) 
            {
                loc1.width = arg3;
            }
            if (arg4 != -1) 
            {
                loc1.height = arg4;
            }
            if (arg5) 
            {
                arg5.addChild(loc1);
            }
            return loc1;
        }

        public static createFlowerBg(arg1: int=0, arg2: int=0, arg3: int=-1, arg4: int=-1, arg5: Object /* flash.display.DisplayObjectContainer */=null, arg6: Boolean=true, arg7: string="LT,LB,RT,RB"): FlowerBg
        {
            var loc1;
            (loc1 = new FlowerBg(arg3, arg4, arg6, arg7)).x = arg1;
            loc1.y = arg2;
            if (arg3 != -1) 
            {
                loc1.width = arg3;
            }
            if (arg4 != -1) 
            {
                loc1.height = arg4;
            }
            if (arg5) 
            {
                arg5.addChild(loc1);
            }
            return loc1;
        }

        public static createLabel(arg1: string, arg2: int, arg3: int, arg4: int=100, arg5: int=25, arg6: string="left", arg7: Object /* flash.display.DisplayObjectContainer */=null, arg8: Boolean=false, arg9: number=16777215): GLabel
        {
            var loc1;
            (loc1 = new GLabel()).x = arg2;
            loc1.y = arg3;
            loc1.setSize(arg4, arg5);
            var loc2;
            (loc2 = loc1.textField.defaultTextFormat).align = arg6;
            loc2.color = arg9;
            loc1.setStyle("textFormat", loc2);
            loc1.htmlText = arg1;
            if (arg8) 
            {
                loc1.filters = [FilterConst.glowFilter];
            }
            if (arg7) 
            {
                arg7.addChild(loc1);
            }
            return loc1;
        }

        public static createPriceLabel(arg1: string, arg2: int, arg3: int, arg4: int=100, arg5: int=25, arg6: string="left", arg7: Object /* flash.display.DisplayObjectContainer */=null, arg8: Boolean=false, arg9: number=16777215): PriceLabel
        {
            var loc1;
            (loc1 = new PriceLabel()).x = arg2;
            loc1.y = arg3;
            loc1.setSize(arg4, arg5);
            var loc2;
            (loc2 = loc1.textField.defaultTextFormat).align = arg6;
            loc2.color = arg9;
            loc1.setStyle("textFormat", loc2);
            loc1.htmlText = arg1;
            if (arg8) 
            {
                loc1.filters = [FilterConst.glowFilter];
            }
            if (arg7) 
            {
                arg7.addChild(loc1);
            }
            return loc1;
        }

        public static createCheckBox(arg1: string, arg2: int=0, arg3: int=0, arg4: int=100, arg5: int=28, arg6: Object /* flash.display.DisplayObjectContainer */=null, arg7: string="GCheckBox"): GCheckBox
        {
            var loc1;
            (loc1 = new GCheckBox()).label = arg1;
            loc1.x = arg2;
            loc1.y = arg3;
            loc1.setSize(arg4, arg5);
            if (arg6) 
            {
                arg6.addChild(loc1);
            }
            loc1.styleName = arg7;
            return loc1;
        }

        public static createRadioButton(arg1: string, arg2: int=0, arg3: int=0, arg4: int=100, arg5: int=28, arg6: Object /* flash.display.DisplayObjectContainer */=null, arg7: string="GRadioButton"): GRadioButton
        {
            var loc1;
            (loc1 = new GRadioButton()).label = arg1;
            loc1.x = arg2;
            loc1.y = arg3;
            loc1.setSize(arg4, arg5);
            if (arg6) 
            {
                arg6.addChild(loc1);
            }
            loc1.styleName = arg7;
            return loc1;
        }

        public static createTileList(arg1: int=0, arg2: int=0, arg3: int=100, arg4: int=100, arg5: Object /* flash.display.DisplayObjectContainer */=null, arg6: string="TileList"): GTileList
        {
            var loc1;
            (loc1 = new GTileList()).scrollPolicy = ScrollPolicy.AUTO;
            loc1.direction = ScrollBarDirection.VERTICAL;
            loc1.styleName = arg6;
            loc1.move(arg1, arg2);
            loc1.setSize(arg3, arg4);
            if (arg5) 
            {
                arg5.addChild(loc1);
            }
            return loc1;
        }

        public static createPageSelecter(arg1: int=0, arg2: int=0, arg3: Object /* flash.display.DisplayObjectContainer */=null, arg4: string="简单状态"): PageSelecter
        {
            var loc1;
            (loc1 = new PageSelecter()).x = arg1;
            loc1.y = arg2;
            if (arg3) 
            {
                arg3.addChild(loc1);
            }
            loc1.mode = arg4;
            return loc1;
        }

        public static createSpBannerAndBg(arg1: int=0, arg2: int=0, arg3: number=200, arg4: number=200, arg5: string="", arg6: Object /* flash.display.DisplayObjectContainer */=null, arg7: Object /* flash.text.TextFormat */=null): Object /* flash.display.Sprite */
        {
            var loc2=null;
            var loc1;
            (loc1 = new Object /* flash.display.Sprite */()).mouseEnabled = false;
            ObjCreate.createBg(0, 0, arg3, arg4, loc1);
            ObjCreate.createBg(-1, -3, arg3 + 4, 35, loc1, "RbListHeader");
            if (arg5) 
            {
                if (!arg7) 
                {
                    (arg7 = new GTextFormat(FontUtil.songtiName, 14, 15788607)).align = flash.text.TextFormatAlign.CENTER;
                }
                (loc2 = ObjCreate.createTextField("", 0, 5, arg3, 20, loc1, arg7)).htmlText = arg5;
            }
            loc1.x = arg1;
            loc1.y = arg2;
            if (arg6) 
            {
                arg6.addChild(loc1);
            }
            return loc1;
        }

        public static createBitmap(arg1: string, arg2: number=0, arg3: number=0, arg4: Object /* flash.display.DisplayObjectContainer */=null): Object /* flash.display.Bitmap */
        {
            var loc1=null;
            if (arg1) 
            {
                loc1 = GlobalClass.getBitmap(arg1);
            }
            else 
            {
                loc1 = UICompomentPool.getUICompoment(flash.display.Bitmap) as Object /* flash.display.Bitmap */;
            }
            UIFactory.setObjAttri(loc1, arg2, arg3, -1, -1, arg4);
            return loc1;
        }

        public static createLoadedBitmap(arg1: string, arg2: number=0, arg3: number=0, arg4: Object /* flash.display.DisplayObjectContainer */=null): Object /* flash.display.Bitmap */
        {
            var url: string;
            var x: number=0;
            var y: number=0;
            var parent: Object /* flash.display.DisplayObjectContainer */=null;
            var bmp: Object /* flash.display.Bitmap */;
            var onloaded: Function;

            var loc1;
            bmp = null;
            onloaded = null;
            url = arg1;
            x = arg2;
            y = arg3;
            parent = arg4;
            onloaded = (arg1: ImageInfo): void
            {
                bmp.bitmapData = arg1.bitmapData;
                return;
            }
            bmp = new Object /* flash.display.Bitmap */();
            UIFactory.setObjAttri(bmp, x, y, -1, -1, parent);
            LoaderManager.instance.load(url, onloaded);
            return bmp;
        }

        public static createGImageBitmap(arg1: string, arg2: number=0, arg3: number=0, arg4: Object /* flash.display.DisplayObjectContainer */=null): GImageBitmap
        {
            var loc1=new GImageBitmap(arg1);
            UIFactory.setObjAttri(loc1, arg2, arg3, -1, -1, arg4);
            return loc1;
        }

        public static createColorBox(arg1: number, arg2: number, arg3: int=16711680, arg4: number=1): Object /* flash.display.Sprite */
        {
            var loc1;
            (loc1 = new Object /* flash.display.Sprite */()).graphics.beginFill(arg3, arg4);
            loc1.graphics.drawRect(0, 0, arg1, arg2);
            loc1.graphics.endFill();
            loc1.cacheAsBitmap = true;
            return loc1;
        }

        public static createTitleTextField(arg1: string, arg2: Object /* flash.text.TextFormat */=null): Object /* flash.text.TextField */
        {
            var loc1=new Object /* flash.text.TextField */();
            loc1.defaultTextFormat = arg2 ? arg2 : GlobalStyle.windowTitle2;
            loc1.filters = [FilterConst.titleFilter, FilterConst.titleShadowFilter];
            loc1.selectable = false;
            loc1.mouseEnabled = false;
            loc1.autoSize = flash.text.TextFieldAutoSize.LEFT;
            loc1.htmlText = arg1;
            return loc1;
        }

        public static createEmbedTitleTextField(arg1: string): Object /* flash.text.TextField */
        {
            var loc1=new Object /* flash.text.TextField */();
            loc1.mouseEnabled = false;
            loc1.embedFonts = true;
            loc1.defaultTextFormat = GlobalStyle.windowTitle;
            loc1.selectable = false;
            loc1.filters = [FilterConst.titleFilter, FilterConst.titleShadowFilter];
            loc1.autoSize = flash.text.TextFieldAutoSize.LEFT;
            loc1.htmlText = arg1;
            return loc1;
        }

        public static setObjAttri(arg1: Object /* flash.display.DisplayObject */, arg2: number=0, arg3: number=0, arg4: number=-1, arg5: number=-1, arg6: Object /* flash.display.DisplayObjectContainer */=null): void
        {
            arg1.x = arg2;
            arg1.y = arg3;
            if (arg4 > 0) 
            {
                arg1.width = arg4;
            }
            if (arg5 > 0) 
            {
                arg1.height = arg5;
            }
            if (arg6) 
            {
                arg6.addChild(arg1);
            }
            return;
        }

        public static createGTabBar(arg1: int, arg2: int, arg3: Array<any>, arg4: int=63, arg5: int=22, arg6: Object /* flash.display.DisplayObjectContainer */=null, arg7: Function=null): GTabBar
        {
            var loc1;
            (loc1 = new GTabBar()).x = arg1;
            loc1.y = arg2;
            loc1.buttonWidth = arg4;
            loc1.height = arg5;
            loc1.horizontalGap = 2;
            loc1.buttonFilters = [FilterConst.glowFilter];
            loc1.dataProvider = arg3;
            if (arg7 != null) 
            {
                loc1.addEventListener(MuiEvent.GTABBAR_SELECTED_CHANGE, arg7);
            }
            if (arg6 != null) 
            {
                arg6.addChild(loc1);
            }
            return loc1;
        }

        public static createGComboBox(arg1: int, arg2: int, arg3: int=100, arg4: int=25, arg5: DataProvider=null, arg6: Object /* flash.display.DisplayObjectContainer */=null, arg7: string="GComboboxStyle"): GComboBox
        {
            var loc1;
            (loc1 = new GComboBox()).move(arg1, arg2);
            loc1.width = arg3;
            loc1.height = arg4;
            loc1.buttonMode = true;
            loc1.styleName = arg7;
            loc1.drawNow();
            loc1.dropdown.setStyle("cellRenderer", MailFriendItemCellRender);
            loc1.dropdown.setStyle("skin", ResouceConst.getScaleBitmap(ImagesConst.WindowCenterB));
            loc1.textField.setStyle("textFormat", new GTextFormat("", 12, 11661308, false, false, false, "", "", flash.text.TextFormatAlign.CENTER));
            if (arg5) 
            {
                loc1.dataProvider = arg5;
            }
            loc1.selectedIndex = 0;
            if (arg6 != null) 
            {
                arg6.addChild(loc1);
            }
            return loc1;
        }

        public static createGNumericStepper(arg1: int, arg2: int, arg3: int=49, arg4: int=22, arg5: Object /* flash.display.DisplayObjectContainer */=null, arg6: int=99, arg7: int=1, arg8: string="NumericStepper", arg9: string="DisabledBg"): GNumericStepper
        {
            var loc1;
            (loc1 = new GNumericStepper()).move(arg1, arg2);
            loc1.setSize(arg3, arg4);
            loc1.styleName = arg8;
            loc1.drawNow();
            loc1.textField.setStyle("upSkin", ResouceConst.getScaleBitmap(arg9));
            loc1.textField.drawNow();
            loc1.maximum = arg6;
            loc1.minimum = arg7;
            if (arg5) 
            {
                arg5.addChild(loc1);
            }
            return loc1;
        }

        public static createNumInput(arg1: int, arg2: int, arg3: Object /* flash.display.DisplayObjectContainer */=null, arg4: int=1, arg5: int=99): NumInput
        {
            var loc1;
            (loc1 = new NumInput()).x = arg1;
            loc1.y = arg2;
            loc1.maxNum = arg5;
            loc1.minNum = arg4;
            if (arg3) 
            {
                arg3.addChild(loc1);
            }
            return loc1;
        }

        public static createFireTip(arg1: string, arg2: number=0, arg3: number=0, arg4: Object /* flash.display.DisplayObjectContainer */=null, arg5: Boolean=false): FireTip
        {
            var loc1;
            (loc1 = new FireTip()).x = arg2;
            loc1.y = arg3;
            if (arg4) 
            {
                arg4.addChild(loc1);
            }
            if (arg5) 
            {
                loc1.htmlText = arg1;
            }
            else 
            {
                loc1.text = arg1;
            }
            return loc1;
        }

        public static createSecTimeView(arg1: string="mm: ss", arg2: number=0, arg3: number=0, arg4: number=200, arg5: number=20, arg6: Object /* flash.display.DisplayObjectContainer */=null, arg7: Object /* flash.text.TextFormat */=null): SecTimerView
        {
            var loc1;
            (loc1 = new SecTimerView()).setParse(arg1);
            ObjCreate.setObjAttri(loc1, arg2, arg3, arg4, arg5, arg6);
            if (arg7) 
            {
                loc1.defaultTextFormat = arg7;
            }
            return loc1;
        }
    }
